<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>蜂蜜旅行运营后台</title>
    <link rel="stylesheet" href="/layui-2.4.2/src/css/layui.css">
    <script type="text/javascript" src="/jquery/jquery-1.8.0.min.js"></script>
    <style>
        .child{
            position: fixed;
            top:50%;
            margin-top: -75px;
        }
    </style>
</head>
<body>
    <div class="layui-container" style="margin-left: 0px;margin-right: 0px;">
        <div class="layui-row">
            <div class="layui-form layui-col-md3 layui-col-md-offset4 child" >
                <div class="layui-form-item">
                    <!--<label class="layui-form-label">用户名</label>-->
                    <div class="layui-input-block">
                        <input type="text" id="accountName" lay-verify="title" autocomplete="off" placeholder="请输入用户名" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <!--<label class="layui-form-label">密码</label>-->
                    <div class="layui-input-block">
                        <input type="password" id="passWord" placeholder="请输入密码" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn" style="width:100%" lay-submit lay-filter="btnLogin" id="btnLogin">登录</button>
                        <!--<button type="reset" class="layui-btn layui-btn-primary"></button>-->
                    </div>
                </div>
            </div>
        </div>
    </div>
<script src="/layui-2.4.2/src/layui.js"></script>
<script>
    layui.use(['element','form','laytpl'], function(){
        var element = layui.element,form=layui.form;
        $("#btnLogin").bind('click',function () {

            if($("#accountName").val() == null || $("#accountName").val() == ""){
                alert("用户名不能为空!");
            }else if($("#passWord").val() == null || $("#passWord").val() == ""){
                alert("密码不能为空!");
            }else {
                $.ajax({
                    type: "POST",
                    traditional: true,
                    url: "/account/doLogin",
                    data:{accountName:$("#accountName").val(),passWord:$("#passWord").val()},
                    dataType: "json",
                    success: function(result){
                        if(result.success == true){
                            window.location.href = "/index";
                        }else{
                            alert("用户名或密码错误");
                        }
                    }
                });
            }
        });
        // form.on('submit(btnLogin)', function(data){
            // if(data)
           // layer.msg(JSON.stringify(data.field));
           //  $.ajax({
           //      type:'POST',
           //      data:JSON.stringify(data.field),
           //      url:'/account/doLogin',
           //      cache:false,
           //      success:function(data){
           //          if(data.success=="true"){
           //              window.href="/index"
           //          }else{
           //              layer.msg("请输入正确的用户名和密码");
           //          }
           //      }
           //  });
          //  return false;
        // });

    });



</script>

</body>
</html>